<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BadgerDB: /home/ubuntu/study/dbmslab/lab2/BufMgr/src/page.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BadgerDB
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_43e0a1f539e00dcfa1a6bc4d4fee4fc2.html">home</a></li><li class="navelem"><a class="el" href="dir_f895279abf3c9abddbac24b9a320b4c6.html">ubuntu</a></li><li class="navelem"><a class="el" href="dir_9223221a80e1dde112a2f0d1c0d6bc8d.html">study</a></li><li class="navelem"><a class="el" href="dir_565d95caf30f979632cef261ad9a6ed4.html">dbmslab</a></li><li class="navelem"><a class="el" href="dir_04bc7b587b42191e49c8f970037360ad.html">lab2</a></li><li class="navelem"><a class="el" href="dir_ccc57109e70d5b9b219c75d9ecb5bc70.html">BufMgr</a></li><li class="navelem"><a class="el" href="dir_57419356550b183f8cb4d89f81ab51b6.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">page.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &quot;exceptions/insufficient_space_exception.h&quot;</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#include &quot;exceptions/invalid_record_exception.h&quot;</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &quot;exceptions/invalid_slot_exception.h&quot;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &quot;exceptions/slot_in_use_exception.h&quot;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &quot;page_iterator.h&quot;</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &quot;page.h&quot;</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160; </div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacebadgerdb.html">badgerdb</a> {</div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; </div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a1e4a3930a92ed6e71ffd253cf224379a">   19</a></span>&#160;<a class="code" href="classbadgerdb_1_1_page.html#a1e4a3930a92ed6e71ffd253cf224379a">Page::Page</a>() {</div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;  initialize();</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;}</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160; </div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="keywordtype">void</span> Page::initialize() {</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">free_space_lower_bound</a> = 0;</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">free_space_upper_bound</a> = <a class="code" href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">DATA_SIZE</a>;</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a> = 0;</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a> = 0;</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">current_page_number</a> = <a class="code" href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">INVALID_NUMBER</a>;</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">next_page_number</a> = <a class="code" href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">INVALID_NUMBER</a>;</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;  data_.assign(<a class="code" href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">DATA_SIZE</a>, <span class="keywordtype">char</span>());</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;}</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160; </div>
<div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#ad0b1e85fe7849fb767dd8c21a8053cf4">   33</a></span>&#160;<a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a> <a class="code" href="classbadgerdb_1_1_page.html#ad0b1e85fe7849fb767dd8c21a8053cf4">Page::insertRecord</a>(<span class="keyword">const</span> std::string&amp; record_data) {</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <span class="keywordflow">if</span> (!<a class="code" href="classbadgerdb_1_1_page.html#a059cb59e3ba05921f9c648fb5dba1068">hasSpaceForRecord</a>(record_data)) {</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <span class="keywordflow">throw</span> <a class="code" href="classbadgerdb_1_1_insufficient_space_exception.html">InsufficientSpaceException</a>(</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        <a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>(), record_data.length(), <a class="code" href="classbadgerdb_1_1_page.html#a6f8c9e50538db4d88306b77c214c09dd">getFreeSpace</a>());</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;  }</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;  <span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number = getAvailableSlot();</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;  insertRecordInSlot(slot_number, record_data);</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;  <span class="keywordflow">return</span> {<a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>(), slot_number};</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;}</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#aad81fa59b469866fbd260c8a640b579f">   43</a></span>&#160;std::string <a class="code" href="classbadgerdb_1_1_page.html#aad81fa59b469866fbd260c8a640b579f">Page::getRecord</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; record_id)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  validateRecordId(record_id);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  <span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>&amp; slot = getSlot(record_id.<a class="code" href="structbadgerdb_1_1_record_id.html#a19ec7b749099499446fdd24d48cec9ef">slot_number</a>);</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;  <span class="keywordflow">return</span> data_.substr(slot.<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a>, slot.<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>);</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;}</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160; </div>
<div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">   49</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">Page::updateRecord</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; record_id,</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;                        <span class="keyword">const</span> std::string&amp; record_data) {</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;  validateRecordId(record_id);</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>* slot = getSlot(record_id.<a class="code" href="structbadgerdb_1_1_record_id.html#a19ec7b749099499446fdd24d48cec9ef">slot_number</a>);</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  <span class="keyword">const</span> std::size_t free_space_after_delete =</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;      <a class="code" href="classbadgerdb_1_1_page.html#a6f8c9e50538db4d88306b77c214c09dd">getFreeSpace</a>() + slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>;</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;  <span class="keywordflow">if</span> (record_data.length() &gt; free_space_after_delete) {</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordflow">throw</span> <a class="code" href="classbadgerdb_1_1_insufficient_space_exception.html">InsufficientSpaceException</a>(</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        <a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>(), record_data.length(), free_space_after_delete);</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;  }</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  <span class="comment">// We have to disallow slot compaction here because we&#39;re going to place the</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="comment">// record data in the same slot, and compaction might delete the slot if we</span></div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="comment">// permit it.</span></div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">deleteRecord</a>(record_id, <span class="keyword">false</span> <span class="comment">/* allow_slot_compaction */</span>);</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  insertRecordInSlot(record_id.<a class="code" href="structbadgerdb_1_1_record_id.html#a19ec7b749099499446fdd24d48cec9ef">slot_number</a>, record_data);</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;}</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160; </div>
<div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">   66</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">Page::deleteRecord</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; record_id) {</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">deleteRecord</a>(record_id, <span class="keyword">true</span> <span class="comment">/* allow_slot_compaction */</span>);</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;}</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160; </div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="keywordtype">void</span> <a class="code" href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">Page::deleteRecord</a>(<span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; record_id,</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;                        <span class="keyword">const</span> <span class="keywordtype">bool</span> allow_slot_compaction) {</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;  validateRecordId(record_id);</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  <a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>* slot = getSlot(record_id.<a class="code" href="structbadgerdb_1_1_record_id.html#a19ec7b749099499446fdd24d48cec9ef">slot_number</a>);</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;  data_.replace(slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a>, slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>, slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>, <span class="charliteral">&#39;\0&#39;</span>);</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160; </div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;  <span class="comment">// Compact the data by removing the hole left by this record (if necessary).</span></div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  std::uint16_t move_offset = slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a>; </div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;  std::size_t move_bytes = 0;</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keywordflow">for</span> (<a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> i = 1; i &lt;= header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a>; ++i) {</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>* other_slot = getSlot(i);</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="keywordflow">if</span> (other_slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a4ea5ad6e73525244bb368181f21fd018">used</a> &amp;&amp; other_slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a> &lt; slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a>) {</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;      <span class="keywordflow">if</span> (other_slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a> &lt; move_offset) {</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        move_offset = other_slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a>;</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;      }</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;      move_bytes += other_slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>;</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;      <span class="comment">// Update the slot for the other data to reflect the soon-to-be-new</span></div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;      <span class="comment">// location.</span></div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;      other_slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a> += slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>;</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    }</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  }</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;  <span class="comment">// If we have data to move, shift it to the right.</span></div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;  <span class="keywordflow">if</span> (move_bytes &gt; 0) {</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keyword">const</span> std::string&amp; data_to_move = data_.substr(move_offset, move_bytes);</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    data_.replace(move_offset + slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>, move_bytes, data_to_move);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;  }</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">free_space_upper_bound</a> += slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a>;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160; </div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  <span class="comment">// Mark slot as unused.</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;  slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a4ea5ad6e73525244bb368181f21fd018">used</a> = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">item_offset</a> = 0;</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;  slot-&gt;<a class="code" href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">item_length</a> = 0;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;  ++header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a>;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160; </div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;  <span class="keywordflow">if</span> (allow_slot_compaction &amp;&amp; record_id.<a class="code" href="structbadgerdb_1_1_record_id.html#a19ec7b749099499446fdd24d48cec9ef">slot_number</a> == header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a>) {</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    <span class="comment">// Last slot in the list, so we need to free any unused slots that are at</span></div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="comment">// the end of the slot list.</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="keywordtype">int</span> num_slots_to_delete = 1;</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    <span class="keywordflow">for</span> (<a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> i = 1; i &lt; header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a>; ++i) {</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;      <span class="comment">// Traverse list backwards, looking for unused slots.</span></div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;      <span class="keyword">const</span> PageSlot* other_slot = getSlot(header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a> - i);</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;      <span class="keywordflow">if</span> (!other_slot-&gt;used) {</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;        ++num_slots_to_delete;</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;      } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;        <span class="comment">// Stop at the first used slot we find, since we can&#39;t move used slots</span></div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;        <span class="comment">// without affecting record IDs.</span></div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;      }</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    }</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a> -= num_slots_to_delete;</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a> -= num_slots_to_delete;</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    header_.<a class="code" href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">free_space_lower_bound</a> -= <span class="keyword">sizeof</span>(PageSlot) * num_slots_to_delete;</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;  }</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;}</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160; </div>
<div class="line"><a name="l00125"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a059cb59e3ba05921f9c648fb5dba1068">  125</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="classbadgerdb_1_1_page.html#a059cb59e3ba05921f9c648fb5dba1068">Page::hasSpaceForRecord</a>(<span class="keyword">const</span> std::string&amp; record_data)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;  std::size_t record_size = record_data.length();</div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  <span class="keywordflow">if</span> (header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a> == 0) {</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    record_size += <span class="keyword">sizeof</span>(<a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>);</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;  }</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  <span class="keywordflow">return</span> record_size &lt;= <a class="code" href="classbadgerdb_1_1_page.html#a6f8c9e50538db4d88306b77c214c09dd">getFreeSpace</a>();</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;}</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160; </div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;<a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>* Page::getSlot(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number) {</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">reinterpret_cast&lt;</span><a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>*<span class="keyword">&gt;</span>(</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;      &amp;data_[(slot_number - 1) * <span class="keyword">sizeof</span>(<a class="code" href="structbadgerdb_1_1_page_slot.html">PageSlot</a>)]);</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;}</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160; </div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;<span class="keyword">const</span> PageSlot&amp; Page::getSlot(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;  <span class="keywordflow">return</span> *<span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span>PageSlot*<span class="keyword">&gt;</span>(</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;      &amp;data_[(slot_number - 1) * <span class="keyword">sizeof</span>(PageSlot)]);</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;}</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160; </div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;<a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> Page::getAvailableSlot() {</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;  <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number = <a class="code" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">INVALID_SLOT</a>;</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;  <span class="keywordflow">if</span> (header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a> &gt; 0) {</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    <span class="comment">// Have an allocated but unused slot that we can reuse.</span></div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <span class="keywordflow">for</span> (<a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> i = 1; i &lt;= header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a>; ++i) {</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;      <span class="keyword">const</span> PageSlot* slot = getSlot(i);</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;      <span class="keywordflow">if</span> (!slot-&gt;used) {</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        <span class="comment">// We don&#39;t decrement the number of free slots until someone actually</span></div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;        <span class="comment">// puts data in the slot.</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;        slot_number = i;</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;        <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;      }</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    }</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;  } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <span class="comment">// Have to allocate a new slot.</span></div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    slot_number = header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a> + 1;</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    ++header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a>;</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    ++header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a>;</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    header_.<a class="code" href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">free_space_lower_bound</a> = <span class="keyword">sizeof</span>(PageSlot) * header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a>;</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;  }</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;  assert(slot_number != <a class="code" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">INVALID_SLOT</a>);</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span><a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a><span class="keyword">&gt;</span>(slot_number);</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;}</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160; </div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;<span class="keywordtype">void</span> Page::insertRecordInSlot(<span class="keyword">const</span> <a class="code" href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">SlotId</a> slot_number,</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;                              <span class="keyword">const</span> std::string&amp; record_data) {</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;  <span class="keywordflow">if</span> (slot_number &gt; header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">num_slots</a> ||</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;      slot_number == <a class="code" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">INVALID_SLOT</a>) {</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    <span class="keywordflow">throw</span> InvalidSlotException(<a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>(), slot_number);</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;  }</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;  PageSlot* slot = getSlot(slot_number);</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;  <span class="keywordflow">if</span> (slot-&gt;used) {</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;    <span class="keywordflow">throw</span> SlotInUseException(<a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>(), slot_number);</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;  }</div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;  <span class="keyword">const</span> <span class="keywordtype">int</span> record_length = record_data.length();</div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;  slot-&gt;used = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;  slot-&gt;item_length = record_length;</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;  slot-&gt;item_offset = header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">free_space_upper_bound</a> - record_length;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;  header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">free_space_upper_bound</a> = slot-&gt;item_offset;</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;  --header_.<a class="code" href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">num_free_slots</a>;</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;  data_.replace(slot-&gt;item_offset, slot-&gt;item_length, record_data);</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;}</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160; </div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;<span class="keywordtype">void</span> Page::validateRecordId(<span class="keyword">const</span> RecordId&amp; record_id)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;  <span class="keywordflow">if</span> (record_id.page_number != <a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>()) {</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;    <span class="keywordflow">throw</span> InvalidRecordException(record_id, <a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>());</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;  }</div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;  <span class="keyword">const</span> PageSlot&amp; slot = getSlot(record_id.slot_number);</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  <span class="keywordflow">if</span> (!slot.used) {</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    <span class="keywordflow">throw</span> InvalidRecordException(record_id, <a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>());</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;  }</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;}</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160; </div>
<div class="line"><a name="l00196"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#aa0fdb281074cd60cb1f1d6ea6d620772">  196</a></span>&#160;<a class="code" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a> <a class="code" href="classbadgerdb_1_1_page.html#aa0fdb281074cd60cb1f1d6ea6d620772">Page::begin</a>() {</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;  <span class="keywordflow">return</span> <a class="code" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a>(<span class="keyword">this</span>);</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;}</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160; </div>
<div class="line"><a name="l00200"></a><span class="lineno"><a class="line" href="classbadgerdb_1_1_page.html#a8e78cba69bef682a5427932485da4608">  200</a></span>&#160;<a class="code" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a> <a class="code" href="classbadgerdb_1_1_page.html#a8e78cba69bef682a5427932485da4608">Page::end</a>() {</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;  <span class="keyword">const</span> <a class="code" href="structbadgerdb_1_1_record_id.html">RecordId</a>&amp; end_record_id = {<a class="code" href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">page_number</a>(), <a class="code" href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">Page::INVALID_SLOT</a>};</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;  <span class="keywordflow">return</span> <a class="code" href="classbadgerdb_1_1_page_iterator.html">PageIterator</a>(<span class="keyword">this</span>, end_record_id);</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;}</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160; </div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;}</div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a3f721c5ce9ef491fdc9d12292f2f4498"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a3f721c5ce9ef491fdc9d12292f2f4498">badgerdb::PageHeader::current_page_number</a></div><div class="ttdeci">PageId current_page_number</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00053">page.h:53</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html">badgerdb::PageSlot</a></div><div class="ttdoc">Slot metadata that tracks where a record is in the data space.</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00077">page.h:77</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a74057ec71412352ef0aa5913bbebed25"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a74057ec71412352ef0aa5913bbebed25">badgerdb::Page::DATA_SIZE</a></div><div class="ttdeci">static const std::size_t DATA_SIZE</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00118">page.h:118</a></div></div>
<div class="ttc" id="anamespacebadgerdb_html"><div class="ttname"><a href="namespacebadgerdb.html">badgerdb</a></div><div class="ttdef"><b>Definition:</b> <a href="buffer_8cpp_source.html#l00017">buffer.cpp:17</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a059cb59e3ba05921f9c648fb5dba1068"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a059cb59e3ba05921f9c648fb5dba1068">badgerdb::Page::hasSpaceForRecord</a></div><div class="ttdeci">bool hasSpaceForRecord(const std::string &amp;record_data) const</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00125">page.cpp:125</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a785a1e756d47fb7f8f3603a3fe8ffcef"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a785a1e756d47fb7f8f3603a3fe8ffcef">badgerdb::Page::INVALID_NUMBER</a></div><div class="ttdeci">static const PageId INVALID_NUMBER</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00123">page.h:123</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_ac71c5a9b3b8644da0ea827f5bd4c5742"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#ac71c5a9b3b8644da0ea827f5bd4c5742">badgerdb::PageHeader::free_space_lower_bound</a></div><div class="ttdeci">std::uint16_t free_space_lower_bound</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00030">page.h:30</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a1bc17754b4ed548f8520a6274b3a4202"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a1bc17754b4ed548f8520a6274b3a4202">badgerdb::Page::deleteRecord</a></div><div class="ttdeci">void deleteRecord(const RecordId &amp;record_id)</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00066">page.cpp:66</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_record_id_html_a19ec7b749099499446fdd24d48cec9ef"><div class="ttname"><a href="structbadgerdb_1_1_record_id.html#a19ec7b749099499446fdd24d48cec9ef">badgerdb::RecordId::slot_number</a></div><div class="ttdeci">SlotId slot_number</div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00039">types.h:39</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_ad0b1e85fe7849fb767dd8c21a8053cf4"><div class="ttname"><a href="classbadgerdb_1_1_page.html#ad0b1e85fe7849fb767dd8c21a8053cf4">badgerdb::Page::insertRecord</a></div><div class="ttdeci">RecordId insertRecord(const std::string &amp;record_data)</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00033">page.cpp:33</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_record_id_html"><div class="ttname"><a href="structbadgerdb_1_1_record_id.html">badgerdb::RecordId</a></div><div class="ttdoc">Identifier for a record in a page.</div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00030">types.h:30</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a7afd8d3c6f22b25e24958ebef773175e"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a7afd8d3c6f22b25e24958ebef773175e">badgerdb::PageHeader::num_free_slots</a></div><div class="ttdeci">SlotId num_free_slots</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00048">page.h:48</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_aa0fdb281074cd60cb1f1d6ea6d620772"><div class="ttname"><a href="classbadgerdb_1_1_page.html#aa0fdb281074cd60cb1f1d6ea6d620772">badgerdb::Page::begin</a></div><div class="ttdeci">PageIterator begin()</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00196">page.cpp:196</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a7cb8260dedb0748d3d75c4b1722dcf3c"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a7cb8260dedb0748d3d75c4b1722dcf3c">badgerdb::PageHeader::next_page_number</a></div><div class="ttdeci">PageId next_page_number</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00058">page.h:58</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a6c233369c611cfb617ba676e11a9d87d"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a6c233369c611cfb617ba676e11a9d87d">badgerdb::PageHeader::num_slots</a></div><div class="ttdeci">SlotId num_slots</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00043">page.h:43</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_af8416fd0be779f473c97b47e797e1c53"><div class="ttname"><a href="classbadgerdb_1_1_page.html#af8416fd0be779f473c97b47e797e1c53">badgerdb::Page::page_number</a></div><div class="ttdeci">PageId page_number() const</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00193">page.h:193</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_header_html_a3af3c066d7651294fb3aae104f404648"><div class="ttname"><a href="structbadgerdb_1_1_page_header.html#a3af3c066d7651294fb3aae104f404648">badgerdb::PageHeader::free_space_upper_bound</a></div><div class="ttdeci">std::uint16_t free_space_upper_bound</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00036">page.h:36</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_ae24e3f6076d6c0a18d4dd2014d540bab"><div class="ttname"><a href="classbadgerdb_1_1_page.html#ae24e3f6076d6c0a18d4dd2014d540bab">badgerdb::Page::updateRecord</a></div><div class="ttdeci">void updateRecord(const RecordId &amp;record_id, const std::string &amp;record_data)</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00049">page.cpp:49</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html_a675118fb03cd9e1b35970a1f10bda9d8"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html#a675118fb03cd9e1b35970a1f10bda9d8">badgerdb::PageSlot::item_length</a></div><div class="ttdeci">std::uint16_t item_length</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00092">page.h:92</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a6f8c9e50538db4d88306b77c214c09dd"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a6f8c9e50538db4d88306b77c214c09dd">badgerdb::Page::getFreeSpace</a></div><div class="ttdeci">std::uint16_t getFreeSpace() const</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00185">page.h:185</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html_a4ea5ad6e73525244bb368181f21fd018"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html#a4ea5ad6e73525244bb368181f21fd018">badgerdb::PageSlot::used</a></div><div class="ttdeci">bool used</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00082">page.h:82</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_insufficient_space_exception_html"><div class="ttname"><a href="classbadgerdb_1_1_insufficient_space_exception.html">badgerdb::InsufficientSpaceException</a></div><div class="ttdoc">An exception that is thrown when a record is attempted to be inserted into a page that doesn't have s...</div><div class="ttdef"><b>Definition:</b> <a href="insufficient__space__exception_8h_source.html#l00021">insufficient_space_exception.h:21</a></div></div>
<div class="ttc" id="anamespacebadgerdb_html_afe9f2f985e7c67e04f76a16f7c4500c8"><div class="ttname"><a href="namespacebadgerdb.html#afe9f2f985e7c67e04f76a16f7c4500c8">badgerdb::SlotId</a></div><div class="ttdeci">std::uint16_t SlotId</div><div class="ttdoc">Identifier for a slot in a page.</div><div class="ttdef"><b>Definition:</b> <a href="types_8h_source.html#l00020">types.h:20</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_aad81fa59b469866fbd260c8a640b579f"><div class="ttname"><a href="classbadgerdb_1_1_page.html#aad81fa59b469866fbd260c8a640b579f">badgerdb::Page::getRecord</a></div><div class="ttdeci">std::string getRecord(const RecordId &amp;record_id) const</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00043">page.cpp:43</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_iterator_html"><div class="ttname"><a href="classbadgerdb_1_1_page_iterator.html">badgerdb::PageIterator</a></div><div class="ttdoc">Iterator for iterating over the records in a page.</div><div class="ttdef"><b>Definition:</b> <a href="page__iterator_8h_source.html#l00023">page_iterator.h:23</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a8e78cba69bef682a5427932485da4608"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a8e78cba69bef682a5427932485da4608">badgerdb::Page::end</a></div><div class="ttdeci">PageIterator end()</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00200">page.cpp:200</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a1e4a3930a92ed6e71ffd253cf224379a"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a1e4a3930a92ed6e71ffd253cf224379a">badgerdb::Page::Page</a></div><div class="ttdeci">Page()</div><div class="ttdef"><b>Definition:</b> <a href="page_8cpp_source.html#l00019">page.cpp:19</a></div></div>
<div class="ttc" id="aclassbadgerdb_1_1_page_html_a4013fab43df72bc52931241575736353"><div class="ttname"><a href="classbadgerdb_1_1_page.html#a4013fab43df72bc52931241575736353">badgerdb::Page::INVALID_SLOT</a></div><div class="ttdeci">static const SlotId INVALID_SLOT</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00128">page.h:128</a></div></div>
<div class="ttc" id="astructbadgerdb_1_1_page_slot_html_a81c14b0e942b0d59e6ac31667d958b79"><div class="ttname"><a href="structbadgerdb_1_1_page_slot.html#a81c14b0e942b0d59e6ac31667d958b79">badgerdb::PageSlot::item_offset</a></div><div class="ttdeci">std::uint16_t item_offset</div><div class="ttdef"><b>Definition:</b> <a href="page_8h_source.html#l00087">page.h:87</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
